package pers.csw.lookBook.controller.front;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import pers.csw.lookBook.common.Res;
import pers.csw.lookBook.entity.Category;
import pers.csw.lookBook.service.CategoryService;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/category")
public class CategoryController {
    @Autowired
    CategoryService categoryService;

    /**
     * 通过上级id获取类别
     * @param pid 上级id
     * @return 返回类别集合
     */
    @GetMapping("/getCategoryByPId/{pid}")
    public Res getCategoryByPId(@PathVariable Integer pid){
        QueryWrapper<Category> queryWrapper =new QueryWrapper<>();
        queryWrapper.eq("pid",pid);
        List<Category> list = categoryService.list(queryWrapper);
        return Res.success(list);
    }
    
}
